<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D旋转</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background-color: pink;
            overflow: hidden;
        }

        .wrapper {
            perspective: 800px;
        }

        .wrapper .turn {
            /* 旋转体位置  */
            position: relative;
            top: 150px;
            left: 50%;
            margin-left: -250px;
            /* 有3d效果时不要使用transform */
            /* transform: translate(-50%,-50%); */

            /* 旋转体样多 */
            width: 500px;
            height: 400px;
            border-radius: 8px;
            background-color: white;
            text-align: center;
            font-size: 28px;

            /* 元素水平垂直居中 */
            display: flex;
            justify-content: center;
            /* align-items: center; */
            padding-top: 40px;

            /* 开启3D效果 */
            transform-style: preserve-3d;

            /* 过渡动画 ease是慢快慢*/
            transition: all 1.6s ease;
            /* 盒子阴影 */
            box-shadow: 0 4px 18px rgba(88, 87, 87, 0.5)
        }

        /* 正反面 */
        .wrapper form {
            /* 正反面重叠 */
            position: absolute;
            /* 开启3D效果 */
            transform-style: preserve-3d;
            /* 背景颜色必须加上 */
            background-color: white;
        }

        /* 注册界面先旋转180deg */
        .wrapper .turn .sign {
            transform: rotateY(180deg);
        }

        /* 鼠标移入旋转180deg */
        /* .wrapper .turn:hover { */
        /* transform: rotateY(180deg); */
        /* } */

        .wrapper .start1 {
            transform: rotateY(180deg);
        }

        .wrapper h2 {
            color: #1f2029;
        }

        .wrapper input {
            width: 80%;
            height: 50px;
            margin-top: 30px;
            border: none;
            outline: none;
            background-color: #4E495D;
            padding: 0 10px;
            box-shadow: 0 4px 8px rgba(31, 32, 41, .5);
            border-radius: 8px;
            font-size: 18px;
            color: white;

            /* 解决登录界面右半边不能触发事件问题 */
            /* transform: translate3d(0, 0, 1px); */
            transform: translateZ(1px);
        }

        .wrapper .btn {
            background-color: #981E61;
            color: white;
            font-size: 24px;
            font-weight: 600;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <div class="turn">
            <form class="login">
                <h2>登录界面</h2>
                <input type="text" placeholder="用户名">
                <input type="password" placeholder="密码">
                <input type="submit" class="btn" value="登 录">
            </form>
            <form class="sign">
                <h2>加入我们</h2>
                <input type="text" placeholder="用户名">
                <input type="password" placeholder="密码">
                <input type="password" placeholder="确定密码">
                <input type="submit" class="btn" value="注 册">
            </form>
        </div>
    </div>

    <script>
        const loginBtn = document.querySelector('.login>.btn')
        const signBtn = document.querySelector('.sign>.btn')
        const turnEle = document.querySelector('.turn')
        loginBtn.addEventListener('click', function (e) {
            e.preventDefault()
            turnEle.classList.add('start1')
        })
        signBtn.addEventListener('click', function (e) {
            e.preventDefault()
            turnEle.classList.remove('start1')
        })
    </script>
</body>

</html>